import config from "./config";

export default  (url,data={},methor='GET')=>{
    return new Promise((resolve, reject)=>{
        wx.request({
            url:config.host+url,
            data,
            methor,
            header:{
                cookie:wx.getStorageSync('cookies')?wx.getStorageSync('cookies').find(item=>item.includes('MUSIC_U')):''
            },
            success:(res)=>{
                if(data.isLogin){
                    wx.setStorage({
                        key:'cookies',
                        data:res.cookies
                    })
                }
                resolve(res.data);
            },
            fail:(err)=>{
                reject(err);
            }
        })
    })
}